from typing import List
import requests
from ..models import WifiDevice


class ControllerClient:
    def __init__(self):
        self.port = 5780
        self.server_ip = "127.0.0.1"
        self.endpoint = f"http://{self.server_ip}:{self.port}"

    def list_devices(self) -> List[WifiDevice]:
        res = requests.get(f"{self.endpoint}/devices/all", timeout=5)
        return list(map(lambda x: WifiDevice.from_dict(x), res.json()))
